home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 248_01 / user.c < prev    next >
Text File  |  1989-08-16  |  1KB  |  60 lines

  1. /*    USER:    User word list processing for MicroSPELL 1.0
  2.         Spell Checker and Corrector
  3.  
  4.         (C)opyright May 1987 by Daniel Lawrence
  5.         All Rights Reserved
  6. */
  7.  
  8. #include    <stdio.h>
  9. #include    "dopt.h"
  10. #include    "dstruct.h"
  11. #include    "ddef.h"
  12.  
  13. uread(fname)        /* open and read in a user dictionary */
  14.  
  15. char *fname;        /* name of dictionary to open */
  16.  
  17. {
  18.     register char *sp;    /* temp string pointer */
  19.     register FILE *ufp;    /* user word list file handle */
  20.     char buf[NSTRING];    /* bufer to hold user word */
  21.  
  22.     /* first, try to open it up..... */
  23.     ufp = fopen(fname, "r");
  24.     if (ufp == NULL) {
  25.         printf("%%Can not find user word list %s\n", fname);
  26.         return(FALSE);
  27.     }
  28.  
  29.     /* if this is the first one, remember the name for later */
  30.     if (*userlist == 0)
  31.         strcpy(userlist, fname);
  32.  
  33.     /* and now, dump the words into the common word list */
  34.     while (numfiltr < MAXCOM) {
  35.         if (fgets(buf, NSTRING - 1, ufp) == NULL)
  36.             break;
  37.         buf[strlen(buf)-1] = 0;    /* get rid of the newline */
  38.  
  39.         /* if it's a blank line, ignore it */
  40.         if (buf[0] == 0)
  41.             continue;
  42.  
  43.         /* get room for it...*/
  44.         if ((sp = malloc(strlen(buf)+1)) == NULL) {
  45.             fclose(ufp);
  46.             return(FALSE);
  47.         }
  48.  
  49.         /* and store it */
  50.         strcpy(sp, buf);
  51.         cword[numfiltr++] = sp;
  52.     }
  53.  
  54.     /* complain if the list is full */
  55.     if (numfiltr == MAXCOM)
  56.         printf("%%User word list space filled\n");
  57.     fclose(ufp);
  58.     return(TRUE);
  59. }
  60.